<!--1.模板-->
<template>
  <div class="app-container">
    <el-steps align-center :active="activeStep" simple style="width: 100%">
      <el-step @click.native="jump(0)" title="基本信息"></el-step>
      <el-step @click.native="isCreate ? false : jump(1)" title="人员信息"></el-step>
      <el-step @click.native="isCreate ? false : jump(2)" title="时间地点"></el-step>
      <el-step @click.native="isCreate ? false : jump(3)" title="调研内容"></el-step>
      <el-step @click.native="isCreate ? false : jump(4)" title="所在地情况"></el-step>
      <!-- <el-step v-if="!commonStu" @click.native="isCreate ? false : jump(5)" title="审核流程"></el-step> -->
    </el-steps>
    <basic-info :isAdmin="isAdmin" ref="basicInfo" v-if="activeStep == 0"></basic-info>
    <teacherstudent :isAdmin="isAdmin" ref="teacherstudent" v-if="activeStep == 1"></teacherstudent>
    <timeplace :isAdmin="isAdmin" ref="timeplace" v-if="activeStep == 2"></timeplace>
    <researchcontent :isAdmin="isAdmin" ref="researchContent" v-if="activeStep == 3"></researchcontent>
    <teamreception :isAdmin="isAdmin" ref="researchContent" v-if="activeStep == 4"></teamreception>
    <!-- <teamexamine :isAdmin="isAdmin" ref="researchContent" v-if="activeStep == 5">></teamexamine> -->
    <!--    <basic-info ref="basicInfo" v-if="activeStep == 0" ></basic-info>
    <Team-plan-step ref="TeamPlan" v-if="activeStep == 1" ></Team-plan-step>
    <rcgc-cases ref="rcgcCases" v-if="activeStep == 2"></rcgc-cases>
    <rcgc-defects ref="rcgcDefects" v-if="activeStep == 3"></rcgc-defects>
    <sample-test-result ref="sampleTestResult" v-if="activeStep == 4 && !showEditTestResult &&!showDetailedResult" v-show="!showEditTestResult&&!showDetailedResult" ></sample-test-result>
    <edit-test-result ref="editTestResult" :testSample="testSample" v-if="activeStep == 4 && showEditTestResult" v-show="showEditTestResult" ></edit-test-result>
    <detailed-result ref="detailedResult" :testSample="testSample" v-if="activeStep == 4 && showDetailedResult" v-show="showDetailedResult" ></detailed-result>
    <process-report ref="processReport" v-if="activeStep == 5"></process-report>
    <Team-accept ref="TeamAccept" v-if="activeStep == 6"></Team-accept> -->
  </div>
</template>
<!--2.js-->
<script>
/* import {downloadGadgets} from "@/api/rcgc/defects"; */
import { mapGetters } from 'vuex';
import CommonUtils from '@/utils/CommonUtils';
export default {
  computed: {
    ...mapGetters(['roles', 'name', 'userName']),
  },
  data() {
    return {
      activeStep: 0,
      isCreate: false,
      showEditTestResult: false,
      showDetailedResult: false,
      testSample: 0,
      isAdmin:false,
      curTeam: {
        TeamName: '',
      },
      commonStu:false,
    };
  },
  created() {
    if(this.roles){
      for (let i = 0; i < this.roles.length; i++) {
          if (this.roles[i] == 'admin' || this.roles[i] == 'common' || this.roles[i] == 'teacher3' || this.roles[i] == 'student-college' || this.roles[i] == 'student-school') {
            this.isAdmin = true;
          }
          this.commonStu = true;
          if (this.roles[i] != 'common-student') {
            this.commonStu = false;
          }
        }
    }
    this.activeStep = +this.$route.query.type;
    const id = CommonUtils.getCurTeamInfo().id;
    if (id == null || id == '') {
      this.isCreate = true;
    } else {
      this.isCreate = false;
    }

    this.curTeam = CommonUtils.getCurTeamInfo();
  },
  methods: {
    jump(value) {
      this.activeStep = value;

      //通过路由跳转，刷新时能停留在当前页面
      const vm = this;
      vm.$router.push({
        //核心语句
        path: '/schoolmatch/teamManage', //跳转的路径
        query: { type: value },
      });
    },

    fatherMethod() {
      this.isCreate = false;
    },

    // 下载小工具
    downloadGadgets() {
      downloadGadgets().then(response => {
        if (response != undefined || response != null) {
          if (response.data.size > 0) {
            let fileName = decodeURI(response.headers.contentfile);

            let contentType = 'application/x-msdownload;';
            let blob = new Blob([response.data], {
              type: contentType + 'charset=UTF-8',
            });
            if (window.navigator.msSaveOrOpenBlob) {
              //IE10+下载
              navigator.msSaveBlob(blob, fileName);
            } else {
              // 非IE下载
              var link = document.createElement('a');
              link.href = window.URL.createObjectURL(blob);
              link.download = fileName;
              link.click();
              //释放内存
              window.URL.revokeObjectURL(link.href);
            }
          }
        }
      });
    },

    // 重选项目
    chooseTeam() {
      let TeamInfo = {
        id: '',
        TeamName: '',
        TeamCode: '',
      };
      CommonUtils.setCurTeamInfo(TeamInfo);
      this.$router.push({
        //核心语句
        path: '/Team/Teams', //跳转的路径
      });
    },
  },
  components: {
    basicInfo: () => import('./components/TeamBasicInfo'),
    timeplace: () => import('./components/TeamTimePlace'),
    teacherstudent: () => import('./components/teacherstudent'),
    researchcontent: () => import('./components/researchContent'),
    teamreception: () => import('./components/TeamReception'),
    // teamexamine: () => import('./components/TeamExamine'),
    /*        //基本信息
        basicInfo: () => import("./components/TeamBasicInfo"),
        //项目计划
        TeamPlanStep: () => import("../external/TeamStep.vue"),
        //测试用例
        rcgcCases: () => import("../cases/index.vue"),
        //缺陷管理
        rcgcDefects: () => import("../defects/index.vue"),
        //结果记录
        sampleTestResult: () => import("./components/sampleTestResult"),
        //过程文档
        processReport:() => import("../processReport/index.vue"),
        //项目验收
        TeamAccept:()=>import("../TeamAccept/index.vue"),
        editTestResult: () => import("./components/editTestResult"),
        detailedResult: () => import("./components/detailedResults"),
 */
  },
};
</script>
<!--3.css样式-->
<style lang="scss" scoped>
.app-container {
  padding-top: 7px;
  height: calc(100% - 30px);
}
.curTeam {
  display: inline-block;
  font-family: 'Helvetica Neue', Helvetica, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei',
    '微软雅黑', Arial, sans-serif;
  font-size: 14px;
  margin-left: 5px;
  margin-bottom: 5px;
  color: #606266;
}
.titleBar {
  float: right;
  position: relative;
  display: inline-block;
  a {
    margin-left: 10px;
  }
}
</style>
